You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With the GitHubFlavor extension, www.link.com was parsed into SpanLink.external("www.link.com") and rendered as <a href="www.link.com">. Browsers resolve that as a relative path, so the link does not reach the external site.
This change prefixes https:// to the link target in AutoLinkParsers, in the same place where email auto-links already get mailto:. The link text stays www.link.com. The GFM spec (section 6.9, "Autolinks (extension)") inserts http. This change uses https instead because most sites serve HTTPS, and a bare www. link gives no way to know the site's scheme. A protocol-relative //www.link.com is not used because EPUB, PDF, and file:// output have no page scheme for it to inherit.
The www parser is only used by GitHubFlavor. reStructuredText standalone links are not affected.
Tests
Updated the two www auto-link tests in GitHubFlavorSpec to expect the https:// target.
GitHubFlavorSpec passes on Scala 2.12 and 3.3.6 (44 tests), and core/test passes on Scala 3.3.6. scalafmtCheck and Test/scalafmtCheck are clean.
The Validate Steward Config failure is unrelated to this change. The job ran scala-steward on Java 11, and scala-steward now needs Java 17 (UnsupportedClassVersionError, class file version 61.0). Main already runs that job on temurin@17, so the branch is now rebased onto main.
Problem with prepending http:// is you don't actually know the protocol used. If anything, the default should be https://. I remember browsers interpreting //www.example.com as an absolute URL, that is also worth looking into
Agreed, https:// is the better default. 1e139e7 switches the inserted scheme to https://, and the two www tests now expect it.
Browsers do treat //www.example.com as an absolute, protocol-relative URL. It takes the scheme of the page it appears on. That works for HTML served over HTTP or HTTPS. Laika also renders EPUB and PDF, and HTML is often opened from disk. There, //www.example.com resolves against file: or has no base scheme, so the link breaks again. A fixed https:// works in every output format. The one case it gets wrong is a site that serves only plain HTTP.
GitHubFlavorSpec passes on Scala 2.12 and 3.3.6, and core/test passes on 3.3.6. With the parser still inserting http://, the two updated tests fail. The PR title and description are updated to match.
This branch has not been deployed
No deployments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With the
GitHubFlavorextension,www.link.comwas parsed intoSpanLink.external("www.link.com")and rendered as<a href="www.link.com">. Browsers resolve that as a relative path, so the link does not reach the external site.This change prefixes
https://to the link target inAutoLinkParsers, in the same place where email auto-links already getmailto:. The link text stayswww.link.com. The GFM spec (section 6.9, "Autolinks (extension)") insertshttp. This change useshttpsinstead because most sites serve HTTPS, and a barewww.link gives no way to know the site's scheme. A protocol-relative//www.link.comis not used because EPUB, PDF, andfile://output have no page scheme for it to inherit.The
wwwparser is only used byGitHubFlavor. reStructuredText standalone links are not affected.Tests
wwwauto-link tests inGitHubFlavorSpecto expect thehttps://target.GitHubFlavorSpecpasses on Scala 2.12 and 3.3.6 (44 tests), andcore/testpasses on Scala 3.3.6.scalafmtCheckandTest/scalafmtCheckare clean.Fixes #797